<?php/* Ramu plan to buy onion. Seller told him that 
If you buy 2kg, the rate will be Rs.10/per kg.
If you buy 5kg, the rate will be Rs.8/per kg.
If you buy 8kg, the rate will be Rs.5/per kg.
If you buy 10kg, the rate will be Rs.4/per kg.
Write a program to calculate the cost of onions for 2kg, 5kg, 8kg and 10kg. Show the output. 
(Your program must contains at least one ARRAY, at least one FOR loop, IF loops or switch case)
*/?>


<?php
$kg=array(2,5,8,10);
//echo $kg['2kg'].'<br>';
//echo $kg['5kg'].'<br>';
//echo $kg['8kg'].'<br>';
//echo $kg['10kg'].'<br>';

$kglen=count($kg);
$perkg;

for($i=0; $i<$kglen; $i++)
{
if($kg[$i]==2)
{
$perkg=10;
}
if($kg[$i]==5)
{
$perkg=8;
}
if($kg[$i]==8)
{
$perkg=5;
}
if($kg[$i]==10)
{
$perkg=4;
}
echo $kg[$i]*$perkg.'<br>';
}
?>
